package br.com.caelum.vraptor.controller;

import java.util.List;

import javax.inject.Inject;

import br.com.caelum.vraptor.Controller;
import br.com.caelum.vraptor.Result;
import br.com.caelum.vraptor.dao.ComissaoDAO;
import br.com.caelum.vraptor.dao.GenericDAO;
import br.com.caelum.vraptor.entidades.Comissao;

@Controller
public class ComissaoController {
	
	@Inject
	private Result result;
	
	@Inject
	private GenericDAO<Comissao> dao;
	
	public void add(){
		
	}
	
	public List<Comissao> list(){
		
		return dao.find();
		
	}
	
	public void save(Comissao comissao){
		
		dao.save(comissao);
		
		result.redirectTo(this).list();
	}
	
	public Comissao edit(Integer CodComissao){
		return dao.find(CodComissao);
	}
	
	public void delete(int codComissao){
		Comissao comissao = new Comissao();
		comissao.setCodComissao(codComissao);
		dao.delete(comissao);
		result.redirectTo(this).list();
	}
	
}
